import { HttpClient } from "@angular/common/http";
import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";

@Component({
  selector: "app-tab2",
  templateUrl: "tab2.page.html",
  styleUrls: ["tab2.page.scss"],
})
export class Tab2Page {
  constructor(public http: HttpClient, public route: ActivatedRoute) {}
  res: Result;
  iseExist;
  doRefresh(e) {
    let url = "http://xiaoshuogebed.applinzi.com/bookrack";

    this.http.get(url).subscribe((res: Result) => {
      this.res = res;
      e.target.complete();
    });
  }
  addHistory(title) {
    let url = "http://xiaoshuogebed.applinzi.com/book_history?title=" + title;
    this.http.get(url).subscribe((res) => {
      this.iseExist = "true";
    });
  }
  ngOnInit(): void {
    let url = "http://xiaoshuogebed.applinzi.com/bookrack";
    this.http.get(url).subscribe((res: Result) => {
      this.res = res;
    });
  }
}
interface Result {
  code: number;
  message: string;
  results: Results[];
}
interface Results {
  bid: number;
  title: string;
  cover: string;
}
